import os
import shutil

delete =[
    "numpy",
    "PyQt5",
    "pip-23.2.1.dist-info",
    "setuptools-49.2.1.dist-info",
    "certifi",
    "PIL"
]

call = True
print("开始打包……")
os.system("pyinstaller --version-file=version.txt -i icon.ico -D -n HDmsgbomber main.py --noconfirm")
print("打包完成。")
for folder in delete:
    try:
        shutil.rmtree(f"dist\\HDmsgbomber\\{folder}")
        print(f"已删除文件夹\"dist\\HDmsgbomber\\{folder}\"。")
    except WindowsError:
        call = False
        print(f"未找到文件夹\"dist\\HDmsgbomber\\{folder}\"。")
    except Exception as error:
        if call:
            print(error)
print("开始编译安装包……")
os.system("start \"D:\\Program Files (x86)\\NSIS\\makensisw.exe\" setup.nsi")
print("编译安装包完成。")